define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'finance_menu/finance/index' + location.search,
                    add_url: 'finance_menu/finance/add',
                    edit_url: 'finance_menu/finance/edit',
                    del_url: '',//finance_menu/finance/del
                    multi_url: 'finance_menu/finance/multi',
                    import_url: 'finance_menu/finance/import',
                    table: 'finance',
                }
            });

            var table = $("#table");
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-editone").data("area",[ '100%' , '100%']);
            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'corporate_name', title: __('Corporate_name'), operate: 'LIKE'},
                        {field: 'city', title: __('City'), operate: 'LIKE'},
                        {field: 'activity_end_time', title: '时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter:function(value,row,index){return value + " 至 " + row.activity_start_time; }},
                        //{field: 'activity_start_time', title: __('Activity_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter:function(value,row,index){return value + " " + row.activity_start_time; }},
                        {field: 'number', title: __('Number')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
